import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDHuangXiaoxi {
	/**ID*/
	id,
	/**名称*/
	name,
	/**简介*/
	desc,
	/**模型*/
	model,
	/**被动增益技能(技能参数在skill表实现，请实现技能等级与黄小西好感度等级绑定）*/
	favorSkillid,
	/**动画文件1*/
	animation_1,
	/**动画文件2*/
	animation_2,
	/**动画文件3*/
	animation_3,
	/**品质1白2绿3蓝4紫5橙6红*/
	color,
	/**解锁条件ID*/
	unlockid,

	/**枚举数量*/
	EnumCount
}



export class CDHuangXiaoxi{
	/**ID*/
	public id: number;
	/**名称*/
	public name: number;
	/**简介*/
	public desc: number;
	/**模型*/
	public model: string;
	/**被动增益技能(技能参数在skill表实现，请实现技能等级与黄小西好感度等级绑定）*/
	public favorSkillid: number[];
	/**动画文件1*/
	public animation_1: string;
	/**动画文件2*/
	public animation_2: string;
	/**动画文件3*/
	public animation_3: string;
	/**品质1白2绿3蓝4紫5橙6红*/
	public color: number;
	/**解锁条件ID*/
	public unlockid: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDHuangXiaoxi.id: return this.id;
			case E_CDHuangXiaoxi.name: return this.name;
			case E_CDHuangXiaoxi.desc: return this.desc;
			case E_CDHuangXiaoxi.model: return this.model;
			case E_CDHuangXiaoxi.favorSkillid: return this.favorSkillid;
			case E_CDHuangXiaoxi.animation_1: return this.animation_1;
			case E_CDHuangXiaoxi.animation_2: return this.animation_2;
			case E_CDHuangXiaoxi.animation_3: return this.animation_3;
			case E_CDHuangXiaoxi.color: return this.color;
			case E_CDHuangXiaoxi.unlockid: return this.unlockid;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDHuangXiaoxi.id: this.id = v; break;
			case E_CDHuangXiaoxi.name: this.name = v; break;
			case E_CDHuangXiaoxi.desc: this.desc = v; break;
			case E_CDHuangXiaoxi.model: this.model = v; break;
			case E_CDHuangXiaoxi.favorSkillid: this.favorSkillid = v; break;
			case E_CDHuangXiaoxi.animation_1: this.animation_1 = v; break;
			case E_CDHuangXiaoxi.animation_2: this.animation_2 = v; break;
			case E_CDHuangXiaoxi.animation_3: this.animation_3 = v; break;
			case E_CDHuangXiaoxi.color: this.color = v; break;
			case E_CDHuangXiaoxi.unlockid: this.unlockid = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDHuangXiaoxi> = new HashMap<number, CDHuangXiaoxi>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDHuangXiaoxi[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDHuangXiaoxi();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].model = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].favorSkillid = [];
			const attrArray = list[i].favorSkillid;
			const arraySize = byte.readInt32();
			for (let j = 0; j < arraySize; j++) {
				attrArray[j] = byte.readInt32();
			}
		}
		for (i = 0; i < size; i++) {
			list[i].animation_1 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].animation_2 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].animation_3 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].color = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].unlockid = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDHuangXiaoxi{
		return this.datas ? this.datas.get(id) : null;
	}
}
